package com.dingyh.shopwebbackground.service.impl;

import com.dingyh.shopwebbackground.entity.Coupons;
import com.dingyh.shopwebbackground.mapper.CouponsMapper;
import com.dingyh.shopwebbackground.service.CouponsService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author dingyuhan
 * @since 2023-02-22
 */
@Service
public class CouponsServiceImpl extends ServiceImpl<CouponsMapper, Coupons> implements CouponsService {

    @Autowired
    CouponsMapper couponsMapper;

    @Override
    public List<Coupons> getAllCoupons() {
        return couponsMapper.getAllCoupons();
    }

    @Override
    public List<Coupons> selectByIdCoupons(Map<String, Object> map) {
        return couponsMapper.selectByIdCoupons(map);
    }

    public List<Coupons> selectByName(Map<String, Object> map) {
        return couponsMapper.selectByName(map);
    }

    @Override
    public boolean removeCoupons(Coupons coupons) {
        try{
            return updateById(coupons);
        }catch (Exception e){
            System.out.println(e);
            return false;
        }
    }

}
